package top.songxs.gmall.seckill.rpc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.seckill.biz.SeckillGoodsBizService;
import top.songxs.gmall.seckill.entity.SeckillGoods;

import java.util.List;

@RestController
@RequestMapping("/api/inner/seckill")
public class SeckillGoodsRpcController {

    @Autowired
    private SeckillGoodsBizService seckillGoodsBizService;



    @GetMapping(value = "/goods/list/today")
    public Result<List<SeckillGoods>> findSeckillGoodsList() {

        List<SeckillGoods> goods = seckillGoodsBizService.findSeckillGoodsList();

        return Result.build(goods, ResultCodeEnum.SUCCESS);
    }

    //提供查询单个秒杀商品详情远程调用接口
    @GetMapping(value = "/goods/detail/{skuId}")
    public Result<SeckillGoods> findSeckillGoodsBySkuId(@PathVariable(value = "skuId") Long skuId) {
      SeckillGoods goods =   seckillGoodsBizService.findSeckillGoodsBySkuId(skuId);
      return Result.ok( goods);
    }

}
